home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / basic / ahnuts.exe / AHNUTS.BAS < prev    next >
Encoding:
BASIC Source File  |  1992-06-21  |  3.1 KB  |  99 lines

  1. DECLARE FUNCTION FindFile$ (spec$, atrb%)
  2. DECLARE FUNCTION FileYear% ()
  3. DECLARE FUNCTION FileMonth% ()
  4. DECLARE FUNCTION FileDay% ()
  5. DECLARE FUNCTION FileHrs% ()
  6. DECLARE FUNCTION FileMin% ()
  7. DECLARE FUNCTION FileSec% ()
  8. DECLARE FUNCTION FileSize& ()
  9. DECLARE FUNCTION FileAtrb% ()
  10. DECLARE FUNCTION FileFound% ()
  11. DECLARE FUNCTION FileError% ()
  12. DEFINT A-Z
  13. '
  14. '----------------------------------------------------------------------------
  15. ' AHNUTS.BAS
  16. '   Example PDS code to be used with "AHNUTS.ASM" library.
  17. '   See "AHNUTS.ASM" for further documentation.
  18. '   Written and placed in the PUBLIC DOMAIN by: Lewis E. Balentine
  19. '   Version date: 20 June 1992
  20. '----------------------------------------------------------------------------
  21. CLS
  22. spec$ = UCASE$(LTRIM$(RTRIM$(COMMAND$)))
  23. ' The next two lines were used for debugging.
  24. ' spec$ = "c:\*.*"
  25. ' SHELL "DIR " + spec$
  26.  
  27. IF spec$ = "" THEN
  28.     PRINT "Simple program to demonstrate 'AHNUTS.ASM' library for MS-PDS."
  29.     PRINT "  Prints directory listing in the format:"
  30.     PRINT "  FILENAME.EXT  LL  MM/DD/YYYY  HH:MM:SS  ZZZ,ZZZ,ZZZ  AA"
  31.     PRINT "  Where:  LL = length of filename"
  32.     PRINT "          MM = month"
  33.     PRINT "          DD = day"
  34.     PRINT "          YYYY = year"
  35.     PRINT "          HH = hour"
  36.     PRINT "          MM = minute"
  37.     PRINT "          SS = second"
  38.     PRINT "          ZZZ,ZZZ,ZZZ = file size"
  39.     PRINT "          AA = file atribute if not zero"
  40.     PRINT "  Syntax:  AHNUTS FileSpec (Default = *.*)"
  41.     PRINT "   ... Press any key to continue .... (ESC to abort)"
  42.     k$ = "": WHILE k$ = "": k$ = INKEY$: WEND
  43.     IF k$ = CHR$(27) THEN END
  44.     spec$ = "*.*"
  45. END IF
  46.  
  47. ' check spec string termination
  48. IF RIGHT$(spec$, 1) = "\" THEN spec$ = spec$ + "*.*"
  49. IF RIGHT$(spec$, 1) = ":" THEN spec$ = spec$ + "*.*"
  50.  
  51. ' try to avoid obvious DOS crital error
  52. IF LEFT$(spec$, 2) = "A:" THEN
  53.     PRINT "Places disk in drive A: and press any key ..."
  54.     k$ = "": WHILE k$ = "": k$ = INKEY$: WEND
  55. END IF
  56. IF LEFT$(spec$, 2) = "B:" THEN
  57.     PRINT "Places disk in drive B: and press any key ..."
  58.     k$ = "": WHILE k$ = "": k$ = INKEY$: WEND
  59. END IF
  60.  
  61. ' for your information
  62. CONST subdirectory = 16
  63. CONST hidden = 2
  64. CONST readonly = 1
  65. CONST volume = 8
  66. CONST archive = 32
  67.  
  68. atrb% = subdirectory + hidden + readonly
  69.  
  70. a$ = FindFile$(spec$, atrb%)            ' first call to library function
  71. l = 0
  72. WHILE a$ <> ""
  73.     l = l + 1
  74.     PRINT a$, ;
  75.     PRINT USING "##  "; LEN(a$);
  76.     PRINT USING "##/"; FileMonth%;
  77.     PRINT USING "##/"; FileDay%;
  78.     PRINT USING "####   "; FileYear%;
  79.     PRINT USING "##:"; FileHrs%;
  80.     PRINT USING "##:"; FileMin%;
  81.     PRINT USING "##   "; FileSec%;
  82.     PRINT USING "###,###,###"; FileSize&;
  83.     IF FileAtrb% <> 0 THEN
  84.         PRINT , FileAtrb%
  85.     ELSE
  86.         PRINT
  87.     END IF
  88.     IF l = 24 THEN
  89.         PRINT "Press any key to continue ....(ESC to abort)";
  90.         k$ = "": WHILE k$ = "": k$ = INKEY$: WEND
  91.         l = 0: PRINT
  92.         IF k$ = CHR$(27) THEN END
  93.     END IF
  94.     a$ = FindFile$("", 0)
  95. WEND
  96. PRINT "Found "; FileFound%; " files. Last error ="; FileError%
  97. END
  98.  
  99.